<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link href="scripts/login_css.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="/scripts/jquery-easyui-1.6.6/jquery.min.js"></script>
		<title>脚本运行管理</title>
		<script type="text/javascript" src="/scripts/project.js"></script>
		<script type="application/javascript">
			$(document).ready(function() {
				$("#login_sub").click(function() {

					var passWord = "";
					var account = "";
					if(jQuery("#name").val() && jQuery("#pwd").val()) {
						account = jQuery("#name").val();
						passWord = jQuery("#pwd").val();
					} else {
						alert("账号或密码输入错误，请重新输入");
						return false;
					}

					var urlString = pro_url + "/login";

					var data = {
						uname: account,
						psw: passWord,

					};
					console.log(JSON.stringify(data));

					jQuery.ajax({
						url: urlString,
						data: JSON.stringify(data),
						dataType: 'json',
						type: 'post',

						success: function(data) {
							console.log("登录返回的数据 = " + JSON.stringify(data));
							if(data.headers.status == 2000) {
								var storage = window.localStorage;
								//本地储存
								storage.setItem("pid", data.body.pid);
								storage.setItem("user", data.body.username);
								window.location.href = 'index.html';

							} else {
								console.log(JSON.stringify(data));
								alert("账号或密码输入错误，请重新输入");

							}

						},
						error: function(XMLHttpRequest, textStatus, errorThrown) {
							console.log(JSON.stringify(XMLHttpRequest, textStatus, errorThrown));
						}
					});

				});
			});
		</script>
	</head>

	<body>
		<div id="login_center">
			<div id="login_area">
				<div id="login_box">
					<div id="login_form">
						<form id="submitForm" action="" method="post">
							<div id="login_tip">
								<span id="login_err" class="sty_txt2"></span>
							</div>
							<div style="color: #FFFFFF;">
								用户名：<input type="text" name="user" class="username" id="name" onkeydown="enterPress()">
							</div>
							<div style="color: #FFFFFF;">
								密&nbsp;&nbsp;&nbsp;&nbsp;码：<input type="password" name="password" class="pwd" id="pwd" onkeydown="enterPress()">
							</div>
							<div id="btn_area">
								<input type="button" class="login_btn" id="login_sub" value="登  录">
								<input type="reset" class="login_btn" id="login_ret" value="重 置">
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>

		<script type="application/javascript">
			function enterPress(e) {  
				var e = e || window.event;
				if(e.keyCode == 13) {
					document.getElementById("login_sub").click();
				}
			}
		</script>
	</body>

</html>